import { director } from "cc";
import { NGameRPCClass, NGameRPCFun, RNGameRPCFun } from "../../../../ngame/decorator/NDecorator";
import { NGameMessage } from "../../../../ngame/protobuf/NGameMessage/NGameMessage";
import IChatsController from "../../../controller/ui/聊天/IChatsController";
import { IChatInfo } from "../../../entitys/EntityConst";

@NGameRPCClass()
export class CNWorld2ChatAction {

    //接收聊天消息
    @RNGameRPCFun()
    static onMessage(message:IChatInfo){

        console.log("CNWorld2ChatAction - onMessage",message);

        director.getScene().getComponentsInChildren(IChatsController)
            .forEach(ichat => {
                ichat.addChat(message);
            })

    }

    //protobuf
    @RNGameRPCFun()
    static onProtobufMessage(message:NGameMessage){
        console.log("CNWorld2ChatAction-onProtobufMessage",message);
    }
    

}
